//
//  UIImage+Extension.swift
//  mall-ios
//
//  Created by Meak Tsui on 2018/12/18.
//  Copyright © 2018 Meak Tsui. All rights reserved.
//

import Foundation
import UIKit

extension UIImage {
    /// 更改图片颜色
    public func change(color : UIColor) -> UIImage{
        UIGraphicsBeginImageContext(self.size)
        color.setFill()
        let bounds = CGRect.init(x: 0, y: 0, width: self.size.width, height: self.size.height)
        UIRectFill(bounds)
        self.draw(in: bounds, blendMode: CGBlendMode.destinationIn, alpha: 1.0)
        
        let tintedImage = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return tintedImage!
    }
}
